package com.jt.provider.controller;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Slf4j //lombok中的这个注解用于告诉lombok
@RefreshScope //此注解描述类时,用于告诉系统底层,当配置中心内容发生变化,此对象要重新创建
@RestController
public class ProviderLogController {
    //import org.slf4j.Logger;  //slf4j是基于门面模式设计的一套API
    //import org.slf4j.LoggerFactory;
    private static final Logger log
            = LoggerFactory.getLogger(ProviderLogController.class);
            //LoggerFactory.getLogger(com.jt.provider.controller.ProviderLogController);

    //http://localhost:8081/provider/log/doLog01
    @GetMapping("/provider/log/doLog01")
    public String doLog01(){
        System.out.println("==doLog==");
        log.trace("==trace==");
        log.debug("==debug==");
        log.info("==info==");
        log.warn("==warn==");
        log.error("==error==");
        return "log config test 01";
    }

    @Value("${logging.level.com.jt:debug}")
    private String logLevel;

    //http://localhost:8081/provider/log/doGetLogLevel
    @GetMapping("/provider/log/doGetLogLevel")
    public String doGetLogLevel(){
        log.info("log level is {}",logLevel);//内部感知
        return "log level is " +logLevel; //外部感知
    }
}
